package service.notice;

import java.util.List;

import util.manager.PageManager;
import util.paramvo.MemberPageListParamVO;
import util.returnvo.NoticeListReturnVO;
import vo.NoticeVO;
import config.PageConfig;
import dao.notice.NoticeDAO;

public class NoticeServiceImpl implements NoticeService{

	private NoticeDAO noticeDAO;

	public void setNoticeDAO(NoticeDAO noticeDAO) {
		this.noticeDAO = noticeDAO;
	}

	@Override
	public NoticeListReturnVO getNoticeList(int member_no, String page) throws Exception {
		int pageNo=1;
		
		if(page!=null && !page.equals("")) pageNo=Integer.parseInt(page);
		
		List<NoticeVO> noticeList=noticeDAO.getNoticeList(new MemberPageListParamVO(member_no, PageConfig.NOTICE_ROW_PER_PAGE, pageNo));
		
		PageManager pageManager=new PageManager(PageConfig.NOTICE_ROW_PER_PAGE, PageConfig.NOTICE_PAGE_PER_GROUP, noticeDAO.countNotice(member_no), pageNo);
		
		return new NoticeListReturnVO(noticeList, pageManager);
	}

	@Override
	public void readNotice(int notice_no) throws Exception {
		noticeDAO.readNotice(notice_no);
	}

	@Override
	public void deleteNotice(String[] notice_no) throws Exception {
		if(notice_no!=null){
			for(String no : notice_no){
				noticeDAO.deleteNotice(Integer.parseInt(no));
			}
		}
	}
	
	
}
